<?php

include_once('framework/ClassLoader.php');

define("DEFAULT_ACTION", "default");

class Controller
{
				private	$_loader;
				private	$_actions;

				function __construct($actions)
				{
								// set up the action map
								$this->_actions = $actions;

								// create class loader
								$this->_loader = new ClassLoader;

								// add path to action classes
								$this->_loader->addPath("logic/action/");
				}

				public function process($http_request)
				{
								// translate the request to an action
								if (isset($this->_actions[$http_request])) 
								{
												$action = $this->_actions[$http_request];
								}
								else 
								{
												$action = $this->_actions[DEFAULT_ACTION];
								}

								// now we can load the action's class (0: class, 1: filename)
								$this->_loader->load($action[0], $action[1]);

								// create a new object of the loaded class
								$action = new $action[0]();

								// perform the requested action
								$action->perform();
				}
}

?>
